package com.lms.demo.autoconfigure.minio;

import io.minio.MinioClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: 李孟帅
 * @CreateTime: 2020-12-25 11:23
 * @Description:
 */
@Configuration
@ConditionalOnMissingBean(MinioTemplate.class)
@ConditionalOnClass(MinioClient.class)
@EnableConfigurationProperties(MinioProperties.class)
@ConditionalOnProperty(name = "lms.minio.endpoint")
public class MinioTemplateAutoConfiguration {

    @Bean
    public MinioTemplate minioTemplate(MinioProperties minioProperties){
        return new MinioTemplate(minioProperties);
    }
}
